package cz.worsik.android.test.rideshare.constants;

import android.content.res.Resources;
import android.graphics.drawable.Drawable;

import cz.worsik.android.test.rideshare.R;

/**
 * Created by 231260 on 30.5.14.
 */
public enum EMenuItem {

    TITLE_SPINNER   (R.string.title_section_spinner),
    SPINNER_ROUTE   (),
    TITLE_MENU      (R.string.title_section_menu),
    MENU_DRIVEWAYS  (R.string.title_section_jizdy, R.string.summary_section_jizdy, R.drawable.ic_drawer_car),
    MENU_PAYMENTS   (R.string.title_section_platby, R.string.summary_section_platby, R.drawable.ic_drawer_coins),
    MENU_CONTACTS   (R.string.title_section_kontakty, R.string.summary_section_kontakty, R.drawable.ic_drawer_contacts),
    MENU_EXIT       (R.string.title_section_ukoncit, R.string.summary_section_ukoncit, R.drawable.ic_drawer_exit);

    Integer resText;
    Integer resSum;
    Integer resIcon;

    Integer resTitle;

    EMenuItem() {
        this.resTitle = null;
        this.resText = null;
        this.resSum = null;
        this.resIcon = null;
    }

    EMenuItem(int resTitle)
    {
        this.resTitle = resTitle;
        this.resText = null;
        this.resSum = null;
        this.resIcon = null;
    }

    EMenuItem(int resText, int resSum, int resIcon)
    {
        this.resTitle = null;
        this.resText = resText;
        this.resSum = resSum;
        this.resIcon = resIcon;
    }

    public int getPosition()
    {
        return ordinal();
    }

    public String getText(Resources res) {
        if (resText == null)
            return null;
        return res.getString(resText);
    }

    public String getSum(Resources res) {
        if (resSum == null)
            return null;
        return res.getString(resSum);
    }

    public Drawable getIcon(Resources res) {
        if (resIcon == null)
            return null;
        return res.getDrawable(resIcon);
    }

    public String getTitle(Resources res) {
        if (resTitle == null)
            return null;
        return res.getString(resTitle);
    }

    public boolean isList() {
        return resText == null & resTitle == null;
    }
}
